﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="Autocomplete.ascx.cs" Inherits="ZLDC.Estate.UserControl.Autocomplete" %>
<script type="text/javascript">
    $(function() {
        $("#<%=TextBox1.ClientID %>").blur(function(){ 
            if(this.value==""){
                $("#<%=AutoInfo.ClientID %>").val('');
            }
        })
        $("#<%=TextBox1.ClientID %>").autocomplete({
            source: function(request, response) {
                $.ajax({
                    url: "/Json/Autocomplete.asmx/<%=AjaxMethod()%>",
                    type: "POST",
                    contentType: "application/json; charset=utf-8",
                    data: '{q:"' + request.term + '",Type:"<%=AjaxType()%>"}',
                    success: function(data) {
                        response($.map(data.d, function(item) {
                        return {
                                label:  item.ShowName,
                                value: item.ShowName,
                                d:item
                            }
                        }));
                    }
                });
            },
            minLength: 2,
            select: function(event, ui) {
                delete ui.item.d.__type;
                $("#<%=AutoInfo.ClientID %>").val($.toJSON(ui.item.d));
                <%=this.ClientChange %>
            },
            open: function() {
                $(this).removeClass("ui-corner-all").addClass("ui-corner-top");
            },
            close: function() {
                $(this).removeClass("ui-corner-top").addClass("ui-corner-all");
            }
        });
       
    })
    
</script>

<asp:TextBox ID="TextBox1"   runat="server" SkinID="tabTextboxOK" Width="96%" CssClass="textdocdown" MaxLength="15"></asp:TextBox>
<asp:HiddenField ID="AutoInfo" runat="server"/>

